﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace BDSim
{
    /// <summary>
    /// RecFreSetWnd.xaml 的交互逻辑
    /// </summary>
    public partial class RecFreSetWnd : Window
    {
        public RecFreSetWnd()
        {
            InitializeComponent();
        }
        //  public Dictionary<ERecType, List<double>> RecType_Fre = new Dictionary<ERecType, List<double>>();//多模接收机多频点

        public Dictionary<ERecType, List<EFrePoint>> RecType_Fre = new Dictionary<ERecType, List<EFrePoint>>();//多模接收机多频点
        public bool One2AllFlag = false;
        // List<CheckBox>
        private void Sure_Click(object sender, RoutedEventArgs e)
        {
            One2AllFlag = false;
            RecType_Fre.Clear();
            if (ckbBD.IsChecked == true)
            {
                List<EFrePoint> BDFreList = new List<EFrePoint>();
                if (ckbBD_B1.IsChecked == true)
                {
                    BDFreList.Add(EFrePoint.BD_B1);
                }
                if (ckbBD_B2.IsChecked == true)
                {
                    BDFreList.Add(EFrePoint.BD_B2);
                }
                if (ckbBD_B3.IsChecked == true)
                {
                    BDFreList.Add(EFrePoint.BD_B3);
                }
                RecType_Fre.Add(ERecType.BD, BDFreList);
            }

            if (ckbGPS.IsChecked == true)
            {
                List<EFrePoint> GPSFreList = new List<EFrePoint>();
                if (ckbGPS_L1.IsChecked == true)
                {
                    GPSFreList.Add(EFrePoint.GPS_L1);
                }
                if (ckbGPS_L2.IsChecked == true)
                {
                    GPSFreList.Add(EFrePoint.GPS_L2);
                }
                if (ckbGPS_L5.IsChecked == true)
                {
                    GPSFreList.Add(EFrePoint.GPS_L5);
                }
                RecType_Fre.Add(ERecType.GPS, GPSFreList);
            }

            if (ckbGLONASS.IsChecked == true)
            {
                List<EFrePoint> GLOFreList = new List<EFrePoint>();
                if (ckbGLO_L1.IsChecked == true)
                {
                    GLOFreList.Add(EFrePoint.GLONASS_L1);
                }
                if (ckbGLO_L2.IsChecked == true)
                {
                    GLOFreList.Add(EFrePoint.GLONASS_L2);
                }
                RecType_Fre.Add(ERecType.GLONASS, GLOFreList);
            }

            if (ckbGALILEO.IsChecked == true)
            {
                List<EFrePoint> GALFreList = new List<EFrePoint>();
                if (ckbGAL_E1.IsChecked == true)
                {
                    GALFreList.Add(EFrePoint.GALILEO_E1);
                }
                if (ckbGAL_E5a.IsChecked == true)
                {
                    GALFreList.Add(EFrePoint.GALILEO_E5a);
                }
                if (ckbGAL_E5a.IsChecked == true)
                {
                    GALFreList.Add(EFrePoint.GALILEO_E5b);
                }
                RecType_Fre.Add(ERecType.GALILEO, GALFreList);
            }
            this.DialogResult = true;
        }

        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ckbBD.IsChecked = false;
            ckbGPS.IsChecked = false;
            ckbGLONASS.IsChecked = false;
            ckbGALILEO.IsChecked = false;
            ckbBD_B1.IsChecked = false;
            ckbBD_B2.IsChecked = false;
            ckbBD_B3.IsChecked = false;
            ckbGPS_L1.IsChecked = false;
            ckbGPS_L2.IsChecked = false;
            ckbGPS_L5.IsChecked = false;
            ckbGLO_L1.IsChecked = false;
            ckbGLO_L2.IsChecked = false;
            ckbGAL_E1.IsChecked = false;
            ckbGAL_E5a.IsChecked = false;
            ckbGAL_E5b.IsChecked = false;
            foreach (var recType in RecType_Fre.Keys)
            {
                switch (recType)
                {
                    case ERecType.BD:
                        ckbBD.IsChecked = true;
                        break;
                    case ERecType.GPS:
                        ckbGPS.IsChecked = true;

                        break;
                    case ERecType.GLONASS:
                        ckbGLONASS.IsChecked = true;

                        break;
                    case ERecType.GALILEO:
                        ckbGALILEO.IsChecked = true;
                        break;
                    default:
                        break;
                }
                for (int i = 0; i < RecType_Fre[recType].Count; i++)
                {
                    switch (RecType_Fre[recType][i])
                    {
                        case EFrePoint.BD_B1:
                            ckbBD_B1.IsChecked = true;
                            break;
                        case EFrePoint.BD_B2:
                            ckbBD_B2.IsChecked = true;
                            break;
                        case EFrePoint.BD_B3:
                            ckbBD_B3.IsChecked = true;
                            break;
                        case EFrePoint.GPS_L1:
                            ckbGPS_L1.IsChecked = true;
                            break;
                        case EFrePoint.GPS_L2:
                            ckbGPS_L2.IsChecked = true;
                            break;
                        case EFrePoint.GPS_L5:
                            ckbGPS_L5.IsChecked = true;
                            break;
                        case EFrePoint.GLONASS_L1:
                            ckbGLO_L1.IsChecked = true;
                            break;
                        case EFrePoint.GLONASS_L2:
                            ckbGLO_L2.IsChecked = true;
                            break;
                        case EFrePoint.GALILEO_E1:
                            ckbGAL_E1.IsChecked = true;
                            break;
                        case EFrePoint.GALILEO_E5a:
                            ckbGAL_E5a.IsChecked = true;
                            break;
                        case EFrePoint.GALILEO_E5b:
                            ckbGAL_E5b.IsChecked = true;
                            break;
                        default:
                            break;
                    }
                }

            }

        }


        private void One2All_Click(object sender, RoutedEventArgs e)
        {
            Sure_Click(sender, e);
            One2AllFlag = true;
            //RecType_Fre.Clear();
            //if (ckbBD.IsChecked == true)
            //{
            //    List<EFrePoint> BDFreList = new List<EFrePoint>();
            //    //double a = FreFlagValue.FreDic[EFrePoint.GALILEO_E1];
            //    if (ckbBD_B1.IsChecked == true)
            //    {
            //        BDFreList.Add(EFrePoint.BD_B1);
            //    }
            //    if (ckbBD_B2.IsChecked == true)
            //    {
            //        BDFreList.Add(EFrePoint.BD_B2);
            //    }
            //    if (ckbBD_B3.IsChecked == true)
            //    {
            //        BDFreList.Add(EFrePoint.BD_B3);
            //    }
            //    RecType_Fre.Add(ERecType.BD, BDFreList);
            //}

            //if (ckbGPS.IsChecked == true)
            //{
            //    List<EFrePoint> GPSFreList = new List<EFrePoint>();
            //    if (ckbGPS_L1.IsChecked == true)
            //    {
            //        GPSFreList.Add(EFrePoint.GPS_L1);
            //    }
            //    if (ckbGPS_L2.IsChecked == true)
            //    {
            //        GPSFreList.Add(EFrePoint.GPS_L2);
            //    }
            //    if (ckbGPS_L5.IsChecked == true)
            //    {
            //        GPSFreList.Add(EFrePoint.GPS_L5);
            //    }
            //    RecType_Fre.Add(ERecType.GPS, GPSFreList);
            //}

            //if (ckbGLONASS.IsChecked == true)
            //{
            //    List<EFrePoint> GLOFreList = new List<EFrePoint>();
            //    if (ckbGLO_L1.IsChecked == true)
            //    {
            //        GLOFreList.Add(EFrePoint.GLONASS_L1);
            //    }
            //    if (ckbGLO_L2.IsChecked == true)
            //    {
            //        GLOFreList.Add(EFrePoint.GLONASS_L2);
            //    }
            //    RecType_Fre.Add(ERecType.GLONASS, GLOFreList);
            //}

            //if (ckbGALILEO.IsChecked == true)
            //{
            //    List<EFrePoint> GALFreList = new List<EFrePoint>();
            //    if (ckbGAL_E1.IsChecked == true)
            //    {
            //        GALFreList.Add(EFrePoint.GALILEO_E1);
            //    }
            //    if (ckbGAL_E5a.IsChecked == true)
            //    {
            //        GALFreList.Add(EFrePoint.GALILEO_E5a);
            //    }
            //    if (ckbGAL_E5a.IsChecked == true)
            //    {
            //        GALFreList.Add(EFrePoint.GALILEO_E5b);
            //    }
            //    RecType_Fre.Add(ERecType.GALILEO, GALFreList);
            //}
            //this.DialogResult = true;
        }
    }
}
